﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;

namespace DocManagerControls.Converters
{
   public class CodificheDataTemplateSelector : DataTemplateSelector
    {

       public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
       {
           DataTemplate dataTemp = null;
           Controls.DynamicControl myControl = null;
           DependencyObject dep = container;

           for (int i = 0; i < 20; i++)
			{
                dep = VisualTreeHelper.GetParent(dep);
                myControl = dep as Controls.DynamicControl;
                if (myControl != null) break;
			}


           myControl = myControl as Controls.DynamicControl;
           if (myControl != null)
               dataTemp = myControl.FindResource("CategorieTemplate") as DataTemplate;

           return dataTemp ;
       }


    }//fC
}
